using System.Collections.Generic;
using System.Data;
using BikeSystem.DAL;
using BikeSystem.Models;
namespace BikeSystem.BLL
{
    public  class AccountManager
    {
        AccountService accountService = new AccountService();

        public void initialize() {
            accountService.initialize();
        }

        public IList<Account> GetAllAccounts()
        {
            return accountService.GetAllAccounts();
        }

        public Account GetAccountByAccountLoginId(string AccountLoginId)
        {
            return accountService.GetAccountByAccountLoginId(AccountLoginId);
        }
        public string InsertAccount(Account account)
        {
            string message = string.Empty;
            Account exitaccount = accountService.GetAccountByAccountLoginId(account.LoginId);
            if (null != exitaccount)
            {
                message = "Unable to add the existing user!";
            }
            else
            {
                accountService.InsertAccount(account);
                message = "Add user success!";
            }
            return message;
        }

        public CommonMessage UpdateAccount(Account account)
        {

            CommonMessage message = new CommonMessage();
            try
            {

                int iret = accountService.UpdateAccount(account);
                if (iret == 0)
                {
                    message.Message = "Updated Success.";
                    message.Success = true;
                }
                else if (iret == -1)
                {
                    message.Message = "Account Not Found";
                    message.Success = false;
                }
            }
            catch (System.Exception ex)
            {
                    message.Message = ex.Message;
                    message.Success = false;
            }

            return message;
        }
        public string  DeleteAccount(string  AccountLoginId)
        {
            return accountService.DeleteAccount(AccountLoginId);


        }
        public Account GetAllAccountByLoginId(string AccountLoginId)
        {
            return accountService.GetAccountByAccountLoginId(AccountLoginId);
        }



        public IList<SystemOption> GetAllOptions()
        {
            return accountService.GetAllOptions();
        }
        public void InsertSystemOption(SystemOption systemOption) {
            accountService.InsertSystemOption(systemOption);
        }

        public string DeleteSystemOption(string optionCode) {

            return accountService.DeleteSystemOption(optionCode);
        }

    }
}
